//package com.pro.common.service.sitecontent.controller;
//
//import com.pro.common.service.sitecontent.model.db.Currency;
//import com.pro.common.service.sitecontent.service.CurrencyService;
//import io.swagger.v3.oas.annotations.Operation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.List;
//import java.util.Map;
//import java.util.Objects;
//
//@RestController
//@RequestMapping("/inner/currency")
//public class CurrencyController {
//
//    @Autowired
//    private CurrencyService currencyService;
//
//    @Operation(summary = "批量更新汇率")
//    @PostMapping("/updateBatchById")
//    public void updateBatchById(@RequestBody List<Currency> currencies) {
//        List<String> codes = currencies.stream().filter(Objects::nonNull).map(Currency::getCode).filter(Objects::nonNull).toList();
//        Map<String, Currency> map = currencyService.getMap(codes);
//        currencyService.updateBatchById(currencies.stream().map(c -> {
//            Currency update = new Currency();
//            update.setId(map.get(c.getCode()).getId());
//            update.setUsdToCurrentRate(c.getUsdToCurrentRate());
//            return update;
//        }).toList());
//    }
//
//}
